<?php include '../template/template_main.tpl'; 
require("../connect/connect.php");
require("../lib/defaultLib.php");

$id = $_GET["id"];

if(isset($_SESSION["id"]) && isset($_SESSION["profile"])){
	if (!(($_SESSION["profile"] == "2") || ($_SESSION["id"] == $id)))
		header("Location: ../index.php");
}
else
	header("Location: ../index.php");


$tabela = getTeamInfo($conn, $id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../css/template.css" />
<link rel="stylesheet" type="text/css" href="../css/corpo_main.css" />
<link rel="stylesheet" type="text/css" href="../css/form.css" />
<script type="text/javascript" src="../js/jquery-1.7.2.js" ></script>
<script type="text/javascript" src="../js/main.js" ></script>

<title>.:MateMatrix:.</title>
<script>

function editEnable(){
	$('input.textbox:text').attr("disabled", false);
    $("#morada").attr("disabled", false);
    $("#save").attr("disabled", false);
    $("#submit").attr("disabled", "disabled"); 
    $("#id").attr("disabled", false);
}

$(document).ready(function() {
	$("#id").attr("disabled", "disabled");
    $('input.textbox:text').attr("disabled", "disabled");
    $("#morada").attr("disabled", "disabled");
    $("#save").attr("disabled", "disabled");
});
</script>
</head>
<body>
	<?php makeHeader(); ?>
	<?php echo $estruturaInicio;?>
	<h1>Editar Equipa:</h1>
	<div id="foto">
		<img src="<?php echo $tabela["avatar_url"]; ?>"></img>
	</div>
	<form action="../admin/updateTeam.php" method="post">
		<div id="teamTable">
		<br />
			<div class="ladoEsq">
				<label>ID</label>
			</div>
			<div class="ladoDir">	
				<input type="text" id="id" name="idEquipa" value="<?php echo $tabela["id"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Login (Nome da Equipa)</label>
			</div>
			<div class="ladoDir">	
				<input type="text" class="textbox" name="nomeEquipa" value="<?php echo $tabela["equipa"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>URL da Foto Equipa</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="foto" value="<?php echo $tabela["avatar_url"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Nome da Escola</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="nomeEscola" value="<?php echo $tabela["escola"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Morada</label>
			</div>
			<div class="ladoDir">
				<textarea id="morada" rows="4" cols="80" name="morada"><?php echo $tabela["morada"]; ?></textarea>
			</div>
			<div class="ladoEsq">
				<label>Codigo Postal</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="cdp" value="<?php echo $tabela["codpostal"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Localidade</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="localidade" value="<?php echo $tabela["localidade"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Professor Responsavel</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="professor" value="<?php echo $tabela["professor"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>E-mail</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="email" value="<?php echo $tabela["email"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Telefone</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="telefone" value="<?php echo $tabela["telefone"]; ?>"/>
			</div>
			<div class="ladoEsq">
				<label>Lista Elementos</label>
			</div>
			<div class="ladoDir">
				<input type="text" class="textbox" name="membros" id="listaMembros" value="<?php echo $tabela["elementos"]; ?>"/>
			</div>
		</div>
		<div class="ladoEsq">
			<input id="submit" class="textbox" type="button" value="Editar" onclick="editEnable()"/>
		</div>
		<div class="ladoDir">
			<input id="save" class="textbox" type="submit" value="Guardar"/>
		</div>
	</form>

	<?php echo $estruturaFim; ?>
	<?php echo $footer;?>
</body>
</html>